<?php

namespace module\app\validate;

use app\Validate;

class Order extends Validate
{
    /**
     * 验证场景.
     *
     * @var array<array>
     */
    protected $scene = [
        'checkout' => ['activity_id', 'coupon_id', 'address_id'],
        'save' => ['activity_id', 'coupon_id', 'address_id', 'memo'],
        'index' => ['page', 'pageSize'],
    ];
    /**
     * Get the validation rules that apply to the request.
     *
     * @var array<string>
     */
    protected $rule = [
        'id' => 'require|integer|max:10',
        'activity_id' => 'require|>:0|exists:app\model\Activity,id|integer', // 活动
        'coupon_id' => 'integer|existsNotEmpty:app\model\UserCoupon,coupon_id', // 优惠券
        'address_id' => 'integer|existsNotEmpty:app\model\UserAddress,id', // 收货地址
        'memo' => 'max:40', // 备注信息
        'page' => 'integer|>:0',
        'pageSize' => 'integer|>:0',
    ];
    /**
     * 验证字段描述
     * 
     * @var array<string>
     */
    protected $field = [
        'activity_id' => '活动', // 活动
        'memo' => '真实姓名', // 真实姓名
        'coupon_id' => '优惠券', // 手机号
        'address_id' => '收货地址', //
        'page' => '页码',
        'pageSize' => '分页大小',
    ];
}